package com.example.fms.enums;

/**
 * 计算规则类型
 */
public enum CalculationRulesEnum {
    STRIP("0", "按条计算"),
    FIXATION("1", "固定计算");

    private String code;
    private String name;

    public static String getNameByCode(String code) {
        for (CalculationRulesEnum value : CalculationRulesEnum.values()) {
            if (value.getCode().equals(code)) {
                return value.getName();
            }
        }
        return null;
    }

    //根据name查Code
    public static String getCodeByName(String name) {
        for (CalculationRulesEnum value : CalculationRulesEnum.values()) {
            if (value.getName().equals(name)) {
                return value.getCode();
            }
        }
        return null;
    }

    CalculationRulesEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }
}
